﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using SMO = Microsoft.SqlServer.Management.Smo;
using WMI = Microsoft.SqlServer.Management.Smo.Wmi;
using System.IO;
using System.Collections;
using System.Data.SqlTypes;

using AG.Utilities;

namespace SharePointOptimizer.DL.SQLServer
{

    public class CollectServerAndServiceData
    {

        public static bool IsSQLServerAccessible(string strconn)
        {
            using (SqlConnection conn = new SqlConnection(strconn))
            {
                try
                {
                    conn.Open();

                    if (conn.State == ConnectionState.Open)
                    {
                        Logger.Debug("Server Accessible, ConnString: " + strconn);
                        return true;
                    }

                }
                catch (Exception sqle1)
                {
                    Logger.Debug("Server not Accessible, ConnString: " + strconn + ", ErrorMessage: " + sqle1.Message);
                       
                    return false;
                }
            }
            return false;
        }
    }
}
